{% from "filtered-jobs.html" import filtered_jobs with context %}
{% extends "layout.html" %}
{% block title %}Batch {{ batch['id'] }}{% endblock %}
{% block head %}
    <script src="{{ base_path }}/common_static/focus_on_keyup.js"></script>
{% endblock %}
{% block content %}
    <h1>Batch {{ batch['id'] }}</h1>
    <h2>Timing</h2>
    <div class="attributes">
      {% for field in ['time_created', 'time_completed', 'duration'] %}
      {% if field in batch %}
      <div>{{ field }}: {{ batch[field] }}</div>
      {% endif %}
      {% endfor %}
    </div>

    {% if 'attributes' in batch %}
    <h2>Attributes</h2>
    <div class="attributes">
      {% for name, value in batch['attributes'].items() %}
      {% if name == "pr" and wb is not none %}
      <div>{{ name }}: <a rel="noopener" href="{{ base_path }}/watched_branches/{{ wb }}/pr/{{ value }}">{{ value }}</a></div>
      {% else %}
      <div>{{ name }}: {{ value }}</div>
      {% endif %}
      {% endfor %}
    </div>
    {% endif %}

    <h2>Jobs</h2>
    {{ filtered_jobs(running, failed, pending, completed) }}
{% endblock %}
